package 初始线程;

//方法1：继承Thread类
class MyThread2 extends Thread{
    @Override
    public void run() {
        while(true){
            System.out.println("111");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo_2 {
    public static void main(String[] args) {
        Thread t = new MyThread2();
        t.start();

        t.getId();

        while(true){
            System.out.println("222");
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
